// 职级 && 职级权限表
const sequelize = require( '../config.js')
const { DataTypes } = require('sequelize')
const rank = sequelize.define('rank', {
    rank_id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: '职级ID'
    },
    rank_name: {
        type: DataTypes.STRING,
        allowNull: false,
        comment: '职级名称'
    },
    rank_school_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: 'school_infos',
            key: 'school_id'
        },
        onDelete: 'CASCADE',
        comment: '院校ID'
    },
  
}, {
    tableName: 'ranks',
    timestamps: false
})

    const rank_sys = sequelize.define('rank_sys', {
        Id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        belong_to_rank_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            references: {
                model: 'ranks',
                key: 'rank_id'
            },
            onDelete: 'CASCADE',
            comment: '所属职级ID'
        },
        page_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            comment: '页面ID'
        },
        page_function_ids: {
            type: DataTypes.STRING,
            allowNull: true,
            comment: '页面功能ID'
        }
    }, {
        tableName: 'rank_sys',
        timestamps: false
}) 
module.exports = {rank,rank_sys}